home *** CD-ROM | disk | FTP | other *** search
/ Cre@te Online 2000 December / Cre@teOnline CD05.iso / MacSoft / XML Instance.sea / XML Instance / Required / plugins / HTMLWindow.jar / horst / SpacerView.class (.txt) < prev    next >
Encoding:
Java Class File  |  2000-03-18  |  2.2 KB  |  67 lines

  1. package horst;
  2.  
  3. import java.awt.Rectangle;
  4.  
  5. public class SpacerView extends View {
  6.    int m_height;
  7.    int m_width;
  8.  
  9.    public SpacerView(View parent, Element e, HTMLPane container) {
  10.       super(parent, e, container);
  11.    }
  12.  
  13.    protected int getMinimumSpan(int axis) {
  14.       return this.getPreferredSpan(axis);
  15.    }
  16.  
  17.    protected int getPreferredSpan(int axis) {
  18.       switch (axis) {
  19.          case 0:
  20.             return this.m_height;
  21.          case 1:
  22.             return this.m_width;
  23.          default:
  24.             return 0;
  25.       }
  26.    }
  27.  
  28.    protected void init() {
  29.       this.m_height = 0;
  30.       this.m_width = 0;
  31.       int sz = 0;
  32.       String val = (String)super.m_elem.getAttribute("size");
  33.       if (val != null) {
  34.          Integer iVal = Utilities.getInteger(val);
  35.          if (iVal != null) {
  36.             sz = iVal;
  37.          }
  38.       }
  39.  
  40.       val = (String)super.m_elem.getAttribute("type");
  41.       if (val != null) {
  42.          if (val.equalsIgnoreCase("vertical")) {
  43.             this.m_height = sz;
  44.          } else if (val.equalsIgnoreCase("horizontal")) {
  45.             this.m_width = sz;
  46.          } else if (val.equalsIgnoreCase("block")) {
  47.             this.m_width = sz;
  48.             this.m_height = sz;
  49.          }
  50.       }
  51.  
  52.       this.m_height = Utilities.setIntegerProperty(this.m_height, "height", super.m_elem.getAttributes());
  53.       this.m_width = Utilities.setIntegerProperty(this.m_width, "height", super.m_elem.getAttributes());
  54.    }
  55.  
  56.    protected Rectangle layout(int x, int y, int width, LayoutInfo info) {
  57.       int viewWidth = Math.max(0, width - info.leftMargin - info.rightMargin);
  58.       if (viewWidth < this.m_width) {
  59.          super.m_bounds.setBounds(x, y, viewWidth, this.m_height);
  60.       } else {
  61.          super.m_bounds.setBounds(x, y, this.m_width, this.m_height);
  62.       }
  63.  
  64.       return super.m_bounds;
  65.    }
  66. }
  67.